//
//  LNTheme.m
//  LNDevelopExample
//
//  Created by wwww on 2018/9/12.
//  Copyright © 2018年 淘发现1iOS. All rights reserved.
//

#import "LNTheme.h"
#import <BGFMDB/BGFMDB.h>

@implementation LNTheme

+(instancetype)shareThemeManager{

    static dispatch_once_t token;
    static LNTheme *sharedInstance_ = nil;
    dispatch_once(&token, ^{
        sharedInstance_ = [[self alloc] init];
    });
    return sharedInstance_;
}

-(void)saveThemeWithTabItem:(LNThemeTabItem *)tabItem{
    
    [tabItem bg_saveOrUpdate];
}

-(void)updateThemeWithTabItem:(LNThemeTabItem *)tabItem{
    
    [tabItem bg_saveOrUpdate];
}

-(LNThemeTabItem *)getThemeWithTag:(NSInteger)tag{
    
    NSString *where = [NSString stringWithFormat:@"where %@ = %@",bg_sqlKey(@"tagID"),bg_sqlValue(@(tag))];
    
    NSArray *results = [LNThemeTabItem bg_find:nil where:where];
    
    if (results.count>0){
        return [results firstObject];
    }
    return nil;
}

@end
